<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Elasticsearch Snapshot & Restore 完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            position: relative;
            font-family: 'Consolas', 'Monaco', monospace;
        }
        
        .code-block::before {
            content: 'JSON';
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 0.75rem;
            color: #666;
            background: #2d2d2d;
            padding: 2px 8px;
            border-radius: 4px;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 1rem;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
            margin-bottom: 2rem;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .list-item {
            position: relative;
            padding-left: 30px;
            margin-bottom: 1rem;
        }
        
        .list-item::before {
            content: '▸';
            position: absolute;
            left: 0;
            top: 0;
            color: #667eea;
            font-weight: bold;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 1.5rem;
            border-radius: 12px;
            margin: 2rem 0;
            position: relative;
            overflow: hidden;
        }
        
        .highlight-box::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: pulse 3s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% { transform: scale(1); opacity: 0.5; }
            50% { transform: scale(1.1); opacity: 0.3; }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .step-number {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 30px;
            height: 30px;
            background: #667eea;
            color: white;
            border-radius: 50%;
            font-weight: bold;
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                Elasticsearch Snapshot & Restore
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                掌握数据备份与恢复的核心技术，构建高可用的 Elasticsearch 集群
            </p>
            <div class="mt-10 flex justify-center space-x-8">
                <div class="text-center">
                    <i class="fas fa-shield-alt text-4xl mb-2"></i>
                    <p class="text-sm">数据安全</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-sync-alt text-4xl mb-2"></i>
                    <p class="text-sm">灾难恢复</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-database text-4xl mb-2"></i>
                    <p class="text-sm">增量备份</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        
        <!-- Introduction -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <p class="text-lg leading-relaxed text-gray-700">
                Elasticsearch 的 <span class="font-bold text-purple-600">Snapshot</span> 和 <span class="font-bold text-purple-600">Restore</span> 功能是保障数据安全和实现灾难恢复的重要手段。通过创建索引数据的快照备份，可以在数据丢失、系统故障或需要迁移时快速恢复，确保业务连续性。
            </p>
        </div>

        <!-- Snapshot Section -->
        <div class="mb-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-camera mr-3 text-purple-600"></i>Snapshot 快照功能
            </h2>
            
            <div class="bg-white rounded-2xl shadow-xl p-8 mb-6 card-hover">
                <p class="text-lg mb-6 text-gray-700">
                    <strong>快照（Snapshot）</strong>是 Elasticsearch 提供的数据备份机制，可以创建索引数据的完整或部分备份，并存储在指定的存储库中。
                </p>
                
                <div class="grid md:grid-cols-2 gap-6 mb-8">
                    <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-xl">
                        <div class="feature-icon">
                            <i class="fas fa-cogs"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">工作原理</h3>
                        <div class="space-y-3">
                            <div class="list-item text-gray-700">定义存储库（文件系统、S3、Azure等）</div>
                            <div class="list-item text-gray-700">执行快照操作，捕获索引数据和元数据</div>
                            <div class="list-item text-gray-700">增量存储，仅保存变更数据</div>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-blue-50 to-indigo-50 p-6 rounded-xl">
                        <div class="feature-icon">
                            <i class="fas fa-tasks"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">应用场景</h3>
                        <div class="space-y-3">
                            <div class="list-item text-gray-700">定期数据备份，防止数据丢失</div>
                            <div class="list-item text-gray-700">灾难恢复，快速恢复业务</div>
                            <div class="list-item text-gray-700">集群迁移和版本升级</div>
                            <div class="list-item text-gray-700">测试环境数据同步</div>
                        </div>
                    </div>
                </div>
                
                <h4 class="text-xl font-bold mb-4 text-gray-800">
                    <span class="step-number">1</span>创建快照示例
                </h4>
                <div class="code-block">
                    <pre><code>PUT /_snapshot/my_backup/snapshot_1
{
  "indices": "index1,index2",
  "ignore_unavailable": true,
  "include_global_state": true
}</code></pre>
                </div>
                
                <div class="mt-6 space-y-2">
                    <p class="text-gray-700"><code class="bg-gray-100 px-2 py-1 rounded text-purple-600">my_backup</code> - 存储库名称</p>
                    <p class="text-gray-700"><code class="bg-gray-100 px-2 py-1 rounded text-purple-600">snapshot_1</code> - 快照名称</p>
                    <p class="text-gray-700"><code class="bg-gray-100 px-2 py-1 rounded text-purple-600">indices</code> - 需要备份的索引列表</p>
                    <p class="text-gray-700"><code class="bg-gray-100 px-2 py-1 rounded text-purple-600">ignore_unavailable</code> - 忽略不可用索引</p>
                    <p class="text-gray-700"><code class="bg-gray-100 px-2 py-1 rounded text-purple-600">include_global_state</code> - 包含集群全局状态</p>
                </div>
            </div>
        </div>

        <!-- Restore Section -->
        <div class="mb-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-undo mr-3 text-purple-600"></i>Restore 恢复功能
            </h2>
            
            <div class="bg-white rounded-2xl shadow-xl p-8 mb-6 card-hover">
                <p class="text-lg mb-6 text-gray-700">
                    <strong>恢复（Restore）</strong>是从快照中恢复数据的过程，可以将数据恢复到原始集群或迁移到新的集群。
                </p>
                
                <h4 class="text-xl font-bold mb-4 text-gray-800">
                    <span class="step-number">2</span>恢复快照示例
                </h4>
                <div class="code-block">
                    <pre><code>POST /_snapshot/my_backup/snapshot_1/_restore
{
  "indices": "index1",
  "ignore_unavailable": true,
  "include_global_state": false
}</code></pre>
                </div>
                
                <div class="highlight-box mt-8">
                    <h4 class="text-2xl font-bold mb-3">
                        <i class="fas fa-lightbulb mr-2"></i>恢复最佳实践
                    </h4>
                    <div class="grid md:grid-cols-2 gap-4 relative z-10">
                        <div>
                            <p class="mb-2"><i class="fas fa-check-circle mr-2"></i>恢复前检查目标索引是否存在</p>
                            <p class="mb-2"><i class="fas fa-check-circle mr-2"></i>可选择性恢复特定索引</p>
                        </div>
                        <div>
                            <p class="mb-2"><i class="fas fa-check-circle mr-2"></i>根据需要决定是否恢复全局状态</p>
                            <p class="mb-2"><i class="fas fa-check-circle mr-2"></i>监控恢复进度和状态</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Workflow Diagram -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h3 class="text-2xl font-bold mb-6 text-center text-gray-800">
                <i class="fas fa-project-diagram mr-2 text-purple-600"></i>Snapshot & Restore 工作流程
            </h3>
            <div class="mermaid">
                graph LR
                    A[Elasticsearch集群] -->|创建快照| B[存储库]
                    B -->|S3| C[云存储]
                    B -->|FS| D[文件系统]
                    B -->|Azure| E[Azure Blob]
                    C -->|恢复数据| F[目标集群]
                    D -->|恢复数据| F
                    E -->|恢复数据| F
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style F fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- Key Features -->
        <div class="grid md:grid-cols-3 gap-6